/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template subFile, choose Tools | Templates
 * and open the template in the editor.
 */
package org.easyjava.util;

import java.io.File;

/**
 *
 * @author 朱雀
 */
public class FileUtil {

	public static boolean delete(String path) {
		boolean success = true;
		File dir = new File(path);
		success = delete(dir);
		return success;
	}

	public static boolean delete(File file) {
		boolean success = true;
		File[] files = file.listFiles();
		if (files != null) {
			for (File subFile : files) {
				if (subFile.isDirectory()) {
					success = delete(subFile);
				} else {
					success = subFile.delete();
				}
				if (!success) {
					break;
				}
			}
		}
		if (files == null || success) {
			success = file.delete();
		}
		return success;
	}
}
